<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .gradient {
            background: linear-gradient(to right, yellow, purple);
            -webkit-background-clip: text;
            color: transparent;
            font-size: 40px;
        }
    </style>
</head>

<body>
    <span class="gradient">
        这是渐变的字体
    </span>
    <div style="width: 20px;height: 20px;background-color: yellow   ;"></div>

</body>

</html>